package com.walter.test;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;

import com.walter.domain.TeacherInfo;
import com.walter.utils.HibernateUtils;

public class Demo1_learn {
	
	@Test
	public void save() {
		//1.获得session
		Session session = HibernateUtils.openSession();
		//2.打开事务
		Transaction tx = session.beginTransaction();
		//3.执行保存
		TeacherInfo t=new TeacherInfo();
		t.setT_name("张三");
		
		session.save(t);
		//4.提交事务
		tx.commit();
		//5.关闭资源
		session.close();
	}
}
